package y.q.h.util.apicontroller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.AllArgsConstructor;
import lombok.Data;

import java.io.Serializable;
import java.util.List;

/**
 * 分页工具类
 *
 * @author chenshun
 * @email sunlightcs@gmail.com
 * @date 2016年11月4日 下午12:59:00
 */
@Data
@AllArgsConstructor
//@ApiModel(value = "分页数据", description ="这是一个公共的返回的分页数据")
public class PageUtils implements Serializable {
    //private static final long serialVersionUID = 1L;
    /*当前页码*/
//	@ApiModelProperty(value = "当前页码")
    private int currentPage;
    /*每页条数*/
//	@ApiModelProperty(value = "每页条数")
    private int pageSize;
    /*记录总数*/
//	@ApiModelProperty(value = "记录总数")
    private long totalSize;
    /*页码总数*/
//	@ApiModelProperty(value = "页码总数")
    private int totalPages;
    //	@ApiModelProperty(value = "返回数据")
    private List<?> list;


    /**
     * 转换分页对象 Page->PageUtils
     *
     * @param page 页
     * @date: 2023/12/30
     * @author SongRenShuo
     */
    public PageUtils(Page<?> page) {
        this.currentPage = (int) page.getCurrent();
        this.pageSize = (int) page.getSize();
        this.totalSize = page.getTotal();
        this.totalPages = (int) page.getPages();
        this.list = page.getRecords();

    }

    public PageUtils() {
        this.currentPage = 1;
        this.pageSize = 10;
    }
}
